﻿using UnityEngine;
using System.Collections;

public class Fire1Script : MonoBehaviour {

	public float fire1Speed;
	public GameObject ExplosionPrefab;
	// Use this for initialization
	void Start () {
	
	}
	
	// Update is called once per frame
	void Update () {
		float amtToMove = fire1Speed * Time.deltaTime;
		transform.Translate (Vector3.up * amtToMove);

		if (transform.position.y > 10.0f) {
			Destroy (this.gameObject);
		}
	}

	void OnTriggerEnter (Collider otherObject){
		if (otherObject.tag == "enemy") {
			EnemyScript enemyScript = (EnemyScript)otherObject.gameObject.GetComponent("EnemyScript");
			Instantiate(ExplosionPrefab, enemyScript.transform.position, enemyScript.transform.rotation);
			enemyScript.SetPositionAndSpeed();

			Destroy(gameObject);

			PlayerScript.scores += 100;
		}
	} //OnTrigger
}
